#include <bits/stdc++.h>

using namespace std;

int main()
{
    vector<int> A = {1,2,3,4};
    vector<int> B = {2,4,5,6};
    vector<int> C;
    int i = 0, j = 0;
    while(i < A.size() && j < B.size())
    {
        if(A.at(i) < B.at(j))
        {
            C.push_back(A.at(i));
            i++;
        }
        else
        {
            C.push_back(B.at(j));
            j++;
        }
    }
    if(i == A.size()){
        while(j < B.size()){
            C.push_back(B.at(j));
            j++;
        }
    }
    else{
        while(i < A.size()){
            C.push_back(A.at(i));
            i++;
        }
    }
    for(i = 0; i < C.size(); i++)
        cout << C[i] << " ";
    return 0;
}
